<template>
	<view class="components-bggrad">
		<view class="container" :style="'height:100vh'">
			<view class="box" v-if="showPage == 1">
				<p>
					<h3>社会单位信息填报</h3>
				</p>
				<p>
					<text>为了给您提供专业的健康服务，我们已为您建立专属的档案。</text>
				</p>
				<p>
					<text>只需要1-2分钟完善信息，我们即可为您推荐适合的健康方案。</text>
				</p>
				<!-- <button class="blueBtn cu-btn bg-green shadow lg" @click="getUserInfo">一键登陆</button> -->
				<button class="blueBtn cu-btn bg-green shadow lg" @click="login">一键登陆</button>
				<!-- <image src="https://cdn.zhoukaiwen.com/icon-guide.png"></image> -->
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				Custom: this.Custom,
				showPage: 1,
			}
		},
		methods: {
			getUserInfo(e) {
				console.log(e);
				uni.getUserProfile({
					desc: 'Wexin', // 这个参数是必须的
					success: res => {
						console.log("用户信息", res.rawData)
					}
				})
			},
			login() {
				
				wx.qy.login({
					success: (res)=> {
						if (res.code) {
							//发起网络请求
							let optsList = {
								url: 'auth/qywx/login',
								method: 'post'
							};
							let paramsList = {
								code:res.code
							};
							this.$request.httpRequest(optsList, paramsList).then(res => {
								if (res.data.success) {
									console.log(res.data);
									const acturalData=res.data.data;
									uni.setStorageSync("access_token",acturalData.access_token);
									uni.setStorageSync("refresh_token",acturalData.refresh_token);
									// uni.reLaunch({
									// 	url:"../index/tabbar"
									// });
									this.$Router.replaceAll({name:"home"})
								}
								else{
									wx.showToast({
									    title: '登陆失败',
										icon:"none"
									});
								}
							});
						} else {
							console.log('登录失败！' + res.errMsg)
						}
					}
				});
				// wx.qy.login().then(res=>{console.log(res);})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.components-bggrad {
		margin: 0;
		width: 100%;
		height: 100vh;
		background-color: #fff;
	}

	.container {
		width: 100%;
		position: absolute;
		text-align: center;
		text-align: left;
		background-image: url(https://cdn.zhoukaiwen.com/icon-guide.png);
		background-size: 70%;
		background-repeat: no-repeat;
		background-position: 50% 35%;
	}

	.box {
		margin-top: 65rpx;
		padding: 20rpx 30rpx 10rpx 30rpx;
		font-size: 26rpx;
		color: #686b78;
		text-align: justify;

		h3 {
			font-size: 38rpx;
			color: #333;
			margin-bottom: 10rpx;
		}
	}

	.blueBtn {
		width: 700rpx;
		margin: 50rpx auto;
		display: block;
		line-height: 80rpx;
		position: absolute;
		bottom: 30rpx;
	}
</style>
